package TUILayer;
import ControlLayer.*;
import ModelLayer.*;
import java.util.Scanner;

/**
 * This is the main menu of the program.
 * 
 * @author (Group2) 
 * @version (2)
 */

public class MainMenu
{
    // instance variables 

    private AddressBook ADDressbook;
    private DVDMenuUI dvdUI;
    private LoanUI loanMenu;
    private AddressBookUI addressUI;

    // The constructor initializez the variables and call the Menu
    public MainMenu()
    {

        ADDressbook=new AddressBook();
        dvdUI=new DVDMenuUI();
        loanMenu=new LoanUI();
        addressUI=new AddressBookUI();
        StartMainMenu();

    }

    // Here are the 4 options that you have  
    public void StartMainMenu()
    {
        boolean exit=false;
        while (!exit) //! means while exit not is true (that is: false)
        {
            // var choise it's that number that you selected
            int choise = textMainMenu();
            switch (choise)
            {
                case 1:
                {
                    // calls the addressbook menu
                    addressUI.AddressBookmenu();
                    break;
                }
                case 2:
                {
                    // calls the dvd menu
                    dvdUI.DVDMenu();
                    break;
                }
                case 3:
                {
                    // calls the loan menu
                    loanMenu.LoanMenu();
                    break;
                }
                case 4:
                {
                    // exit of the program
                    End();
                    exit = true;
                    break;
                }

            }

        }// end else
    }

    // Here it display the option that you have
    private int textMainMenu()
    {       
        // creates a keyboard object to read input
        Scanner keyboard = new Scanner(System.in);
        System.out.println("\f *** MainMenu ***");
        System.out.println(" (1)AddressBook");
        System.out.println(" (2)DVDs");
        System.out.println(" (3)Loan");
        System.out.println(" (4)Close");
        System.out.print("\n Make your choise: ");

        int choise = keyboard.nextInt();
        // Return the choise
        return choise;
    }  

    // Print "bye bye" when you close the program
    private void End()
    {
        System.out.println("Bye bye");
    }

}

